package other.edan.intlpass;

import com.alibaba.fastjson.JSONArray;
import com.rkhd.platform.sdk.api.annotations.RequestMethod;
import com.rkhd.platform.sdk.api.annotations.RestApi;
import com.rkhd.platform.sdk.api.annotations.RestMapping;
import com.rkhd.platform.sdk.api.annotations.RestQueryParam;
import com.rkhd.platform.sdk.log.Logger;
import com.rkhd.platform.sdk.log.LoggerFactory;
import other.edan.intlpass.utils.HCXObjectService;
import other.edan.intlpass.utils.Result;

/**
 * @Description: pass开发以及页面需要到的自定义api
 * @Author: 黎炎松
 * @Date: 2024/8/22 10:53
 */
@RestApi(baseUrl = "/custom")
public class PassCustomApi {

    private static final Logger LOGGER = LoggerFactory.getLogger();

    public static void main(String[] args) {
        PassCustomApi passCustomApi = new PassCustomApi();
        passCustomApi.getRegProductDetailsList(3424403205642709L);
    }

    /**
     * 获取产品详情列表
     * @param masterId
     * @return
     */
    @RestMapping(value = "/getRegProductDetailsList", method = RequestMethod.GET)
    public Result getRegProductDetailsList(@RestQueryParam(name = "masterId") Long masterId) {
        LOGGER.info("获取产品详情列表:" + masterId);
        String sql = "select id,productLine__c,productModel__c,productModel__c.productName productName,remark__c,productSeries__c " +
                " from RegProductDetails__c where certificateRegistration__c = " + masterId;
        JSONArray detailList = HCXObjectService.queryAllUseXoql(sql);
        System.out.println("detailList = " + detailList);
        LOGGER.info("detailList:" + detailList.size());
        return Result.success(detailList);
    }


}
